-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(core-flows): avoid overriding customer and region from setPricingContext hook result #14022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 010da73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 8 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| const baseContext = { | ||
| ...filterObjectByKeys(cart, cartFieldsForPricingContext), | ||
| customer: cart.customer, | ||
| region: cart.region, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Pricing Context Ignores Custom Objects
After allowing setPricingContextResult to provide custom region and customer objects, the code still uses cart.region?.currency_code, cart.region_id, and cart.customer_id as fallbacks. This creates inconsistency when a custom region or customer is provided, causing the context to have mismatched IDs and currency codes that don't match the custom objects.
Summary
Updated context passed for each variant when calculating prices so that
regionandcustomercoming fromsetPricingContextare not overriden if provided.Please provide answer here
Otherwise you can't provide your own
regionandcustomerobjects with additional information and you are left with the ones we pass as part of the cart object to the workflows that execute the hook.Please provide answer here
Changed the order in which we define the default
regionandcartfields, taking their value from the cart, to before the destructuredsetPricingContextResult.Please provide answer here
Testing — How have these changes been tested, or how can the reviewer test the feature?
Please provide answer here
Examples
Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.
This helps with documentation and ensures maintainers can quickly understand and verify the change.
// Example usageChecklist
Please ensure the following before requesting a review:
yarn changesetand follow the promptsAdditional Context
fixes #13990
closes SUP-2647
Note
Adjust pricing context merge order so
setPricingContext-providedcustomerandregionare not overridden when calculating variant prices.packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts, change merge order when buildingbaseContextsocustomerandregionfromsetPricingContextResulttake precedence over cart-derived values when pricing variants.@medusajs/core-flows.Written by Cursor Bugbot for commit 010da73. This will update automatically on new commits. Configure here.